//============================================================================
// Name        : SMSSSH.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string>
using namespace std;

bool newMessageAvailable = true;
bool newOutputAvailable = false;

//temporary
string messageIn;

void sendToSsh(string message) {
	cout << "This is sent to the phone via GSM=" << message << endl;
}

void checkCommands(string command) {
	//connect
	//dc
	//list
	//verbosity
	//
}

string readNewMessage() {
	return messageIn;
}

void onNewMessage() {
	string rawMessage = readNewMessage();
	int loc = rawMessage.find('}', 0);
	//split into the command and the ssh command
	//command no longer contains the '{' or the '}'
	string command = rawMessage.substr(1, loc - 1);
	//message does not contain the '}' either
	string message = rawMessage.substr(loc + 1, rawMessage.length());
	cout << "Raw=" << rawMessage << "\tCommand=" << command << "\tMessage="
			<< message << endl;
	checkCommands(command);
	sendToSsh(message);
}

void onNewOutput() {

}

int main() {
	while (true) {
		cout << "Enter the message that the cellphone sent: ";
		getline(cin, messageIn);
		if (newMessageAvailable) {
			onNewMessage();
		}
		if (newOutputAvailable) {
			onNewOutput();
		}
	}
	return 0;
}
